package com.cci.kangdao.service.impl;

import com.cci.kangdao.aop.UserThreadLocal;
import com.cci.kangdao.dao.OcrRecordLogMapper;
import com.cci.kangdao.dao.model.OcrRecordLog;
import com.cci.kangdao.dao.model.UserT;
import com.cci.kangdao.dto.BaseResponse;
import com.cci.kangdao.service.OcrRecordLogService;
import com.cci.kangdao.utilTool.LocalTimeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @description:
 * @author: joe
 * @company: CTY
 * @since: 2023/11/14 21:57
 * @version: V1.0
 **/
@Service
public class OcrRecordLogServiceImpl implements OcrRecordLogService {
    @Resource
    private OcrRecordLogMapper ocrRecordLogMapper;

    @Override
    public BaseResponse ocrRecordLogSave(OcrRecordLog ocrRecordLog) {
        UserT userT = UserThreadLocal.get();
        ocrRecordLog.setFlag(0);
        ocrRecordLog.setCreator(userT.getId());
        ocrRecordLog.setCreateTime(LocalTimeUtil.getRealCurrentTime());
        ocrRecordLog.setUserId(userT.getId());
        ocrRecordLog.setPhone(userT.getPhone());
        ocrRecordLog.setRoleNo(StringUtils.isNotBlank(ocrRecordLog.getRoleNo())?ocrRecordLog.getRoleNo():"R0033");
        int i = ocrRecordLogMapper.insertSelective(ocrRecordLog);
        if(i>0){
            return BaseResponse.success();
        }else {
            return BaseResponse.error(-99,"添加失败");
        }
    }
}
